home *** CD-ROM | disk | FTP | other *** search
/ EnigmA Amiga Run 1997 February / EnigmA AMIGA RUN 15 (1997)(G.R. Edizioni)(IT)[!][issue 1997-02][PLANET CD V].iso / enigma / earcd / emula / arosdv19.lha / AROS / exec / vacate.c < prev    next >
C/C++ Source or Header  |  1996-10-24  |  2KB  |  91 lines

  1. /*
  2.     (C) 1995-96 AROS - The Amiga Replacement OS
  3.     $Id: vacate.c,v 1.5 1996/10/24 15:50:58 aros Exp $
  4.     $Log: vacate.c,v $
  5.     Revision 1.5  1996/10/24 15:50:58  aros
  6.     Use the official AROS macros over the __AROS versions.
  7.  
  8.     Revision 1.4  1996/08/13 13:56:09  digulla
  9.     Replaced AROS_LA by AROS_LHA
  10.     Replaced some AROS_LH*I by AROS_LH*
  11.     Sorted and added includes
  12.  
  13.     Revision 1.3  1996/08/01 17:41:21  digulla
  14.     Added standard header for all files
  15.  
  16.     Desc:
  17.     Lang: english
  18. */
  19. #include "exec_intern.h"
  20. #include "semaphores.h"
  21.  
  22. /*****************************************************************************
  23.  
  24.     NAME */
  25.     #include <exec/semaphores.h>
  26.     #include <clib/exec_protos.h>
  27.  
  28.     AROS_LH2(void, Vacate,
  29.  
  30. /*  SYNOPSIS */
  31.     AROS_LHA(struct SignalSemaphore  *, sigSem, A0),
  32.     AROS_LHA(struct SemaphoreMessage *, bidMsg, A1),
  33.  
  34. /*  LOCATION */
  35.     struct ExecBase *, SysBase, 91, Exec)
  36.  
  37. /*  FUNCTION
  38.     Release a lock obtained with Procure. This will even work if the
  39.     message is not yet replied - the request will be cancelled and the
  40.     message replied. In any case the ssm_Semaphore field will be set to
  41.     NULL.
  42.  
  43.     INPUTS
  44.     sigSem - Pointer to semaphore structure.
  45.     bidMsg - Pointer to struct SemaphoreMessage.
  46.  
  47.     RESULT
  48.  
  49.     NOTES
  50.  
  51.     EXAMPLE
  52.  
  53.     BUGS
  54.  
  55.     SEE ALSO
  56.     Procure()
  57.  
  58.     INTERNALS
  59.  
  60.     HISTORY
  61.     29-10-95    digulla automatically created from
  62.                 exec_lib.fd and clib/exec_protos.h
  63.  
  64. *****************************************************************************/
  65. {
  66.     AROS_LIBFUNC_INIT
  67.  
  68.     /* Arbitrate for the semaphore structure */
  69.     Forbid();
  70.  
  71.     /* Check if the message is still posted. */
  72.     if(bidMsg->ssm_Message.mn_Node.ln_Type==NT_MESSAGE)
  73.     {
  74.     /* Yes. Remove it from the semaphore's waiting queue. */
  75.     Remove(&bidMsg->ssm_Message.mn_Node);
  76.  
  77.     /* And reply the message. */
  78.     ReplyMsg(&bidMsg->ssm_Message);
  79.     }else
  80.     /* The semaphore is already locked. Release the lock. */
  81.     ReleaseSemaphore(sigSem);
  82.  
  83.     /* Clear the semaphore field. */
  84.     bidMsg->ssm_Semaphore=NULL;
  85.  
  86.     /* All done. */
  87.     Permit();
  88.     AROS_LIBFUNC_EXIT
  89. } /* Vacate */
  90.  
  91.